home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 44 / PC Actual CD 44.iso / Linux / Cygwin / full.exe / Disk1 / data1.cab / Tools / H-i586-cygwin32 / i586-cygwin32 / include / mingw32 / varargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-04  |  2.4 KB  |  96 lines

  1. /*
  2.  * varargs.h
  3.  *
  4.  * Old, non-ANSI facilities for stepping through a list of function
  5.  * arguments of an unknown number and type.
  6.  * TODO: Has not been tested. Essentially it copies the GCC version.
  7.  *
  8.  * NOTE: I believe GCC supplies a version of this header as well (in
  9.  *       addition to stdarg.h and others). The GCC version is more
  10.  *       complex, to deal with many alternate systems, but it is
  11.  *       probably more trustworthy overall. It would probably be
  12.  *       better to use the GCC version.
  13.  *
  14.  * NOTE: These are incompatible with the versions in stdarg.h and should
  15.  *       NOT be mixed! All new code should use the ANSI compatible versions.
  16.  *
  17.  * This file is part of the Mingw32 package.
  18.  *
  19.  * Contributors:
  20.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  21.  *
  22.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  23.  *
  24.  *  This source code is offered for use in the public domain. You may
  25.  *  use, modify or distribute it freely.
  26.  *
  27.  *  This code is distributed in the hope that it will be useful but
  28.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  29.  *  DISCLAMED. This includes but is not limited to warranties of
  30.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  31.  *
  32.  * $Revision: 1.1 $
  33.  * $Author: noer $
  34.  * $Date: 1998/10/10 00:51:16 $
  35.  *
  36.  */
  37.  
  38. #ifndef    __STRICT_ANSI__
  39.  
  40. #ifndef _VARARGS_H_
  41. #define _VARARGS_H_
  42.  
  43. /* 
  44.  * I was told that Win NT likes this.
  45.  */
  46. #ifndef _VA_LIST_DEFINED
  47. #define _VA_LIST_DEFINED
  48. #endif
  49.  
  50. #ifndef RC_INVOKED
  51.  
  52. #ifndef _VA_LIST
  53. #define    _VA_LIST
  54. typedef char* va_list;
  55. #endif
  56.  
  57. /*
  58.  * Amount of space required in an argument list (ie. the stack) for an
  59.  * argument of type t.
  60.  */
  61. #define __va_argsiz(t)    \
  62.     (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
  63.  
  64. #define    va_alist    __builtin_va_alist
  65.  
  66. /*
  67.  * Used in old style argument lists IIRC. The ellipsis forces the compiler
  68.  * to realize this is a vararg function.
  69.  */
  70. #define va_dcl        int __builtin_va_alist; ...
  71.  
  72. #define va_start(ap)    \
  73.     ((ap) = ((va_list) &__builtin_va_alist))
  74. #define va_end(ap)    ((void)0)
  75.  
  76.  
  77. /*
  78.  * Increment ap to the next argument in the list while returing a
  79.  * pointer to what ap pointed to first, which is of type t.
  80.  *
  81.  * We cast to void* and then to t* because this avoids a warning about
  82.  * increasing the alignment requirement.
  83.  */
  84.  
  85. #define va_arg(ap, t)                    \
  86.      (((ap) = (ap) + __va_argsiz(t)),        \
  87.       *((t*) (void*) ((ap) - __va_argsiz(t))))
  88.  
  89.  
  90. #endif    /* Not RC_INVOKED */
  91.  
  92. #endif    /* Not _VARARGS_H_ */
  93.  
  94. #endif    /* Not __STRICT_ANSI__ */
  95.  
  96.